package com.wn.ziroom.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wn.ziroom.entity.Streets;
import com.wn.ziroom.service.StreetsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-23 02:27:54
 */
@Controller
@RequestMapping("/streets")
public class StreetsController {

    @Autowired
    private com.wn.ziroom.service.StreetsService streetsService;

    @ResponseBody
    @Cacheable(value = "street",key = "#code")
    @GetMapping("/getStreetsByArea")
    public List<Streets> getStreetsByArea(String code) {
        LambdaQueryWrapper<Streets> streetsLambdaQueryWrapper = new LambdaQueryWrapper<>();
        streetsLambdaQueryWrapper.eq(Streets::getAreaCode, code).eq(Streets::getProvinceCode, 31);

        return streetsService.list(streetsLambdaQueryWrapper);
    }

//
//    @ResponseBody
//    @PostMapping("/showStreets")
//    public List<Streets> showStreets(@RequestParam("areaCode") Integer areaCode){
//        List<Streets> streetsList = streetsService.findListByAreaCode(areaCode);
//        return streetsList;
//    }

}

